import 'package:flutter/material.dart';
import 'package:online_study/theme/colors.dart';
import 'package:online_study/theme/size.dart';

//课程的item(视频(已学习,未学习)图文(已学习,未学习))
class CourseDetailsItemPage extends StatefulWidget {
  @override
  _CourseItemState createState() => _CourseItemState();
}

class _CourseItemState extends State<CourseDetailsItemPage> {
  bool isVideo = true;
  bool hasPractice = true;
  bool hasStudy = true;

  @override
  Widget build(BuildContext context) {
    return Container(
      color: ThemeColor.colorWhite,
      child: Row(
        children: [_buildLeft(), _buildRight()],
      ),
    );
  }

  Widget _buildLeft() {
    return Expanded(
        child: Container(
      padding: EdgeInsets.only(
          top: ThemeSize.height12,
          bottom: ThemeSize.height12,
          left: ThemeSize.width19),
      child: Column(
        children: [
          Row(
            children: [
              buildLeftIcon(),
              Text("节开班典礼开班典礼开班",
                  style: TextStyle(
                      color: ThemeColor.color1485EE, fontSize: ThemeSize.sp13))
            ],
          ),
          !hasStudy
              ? Container()
              : Container(
                  alignment: Alignment.topLeft,
                  margin: EdgeInsets.only(
                      top: ThemeSize.height12, left: ThemeSize.width12),
                  child: Text("已学习100%",
                      style: TextStyle(
                          color: ThemeColor.color1485EE,
                          fontSize: ThemeSize.sp10))),
        ],
      ),
    ));
  }

  Widget _buildRight() {
    if (hasPractice) {
      return Container(
        alignment: Alignment.center,
        height: ThemeSize.height22,
        width: ThemeSize.width50,
        decoration: BoxDecoration(
            color: ThemeColor.color1485EE,
            borderRadius: BorderRadius.only(
                topLeft: Radius.circular(ThemeSize.height12),
                bottomLeft: Radius.circular(ThemeSize.height12))),
        child: Text("章节练习",
            style: TextStyle(
                color: ThemeColor.colorWhite, fontSize: ThemeSize.sp10)),
      );
    } else {
      return Container();
    }
  }

  Widget buildLeftIcon() {
    if (isVideo) {
      return Icon(Icons.play_circle_filled_rounded,
          color: ThemeColor.color1485EE);
    }
    return Container();
  }
}
